﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Abp.Auditing;
using Abp.Web.Models;
using FwProject.Com;
using FwProject.Controllers;
using Microsoft.AspNetCore.Mvc;

namespace FwProject.Web.Shop.Controllers
{
    /// <summary>
    /// 评论
    /// </summary>
    public class ReviewsController : FwProjectControllerBase
    {
        private readonly ICommodityReviewsAppService _commodityReviewsAppService;
        public ReviewsController(ICommodityReviewsAppService commodityReviewsAppService)
        {
            _commodityReviewsAppService = commodityReviewsAppService;
        }

        public IActionResult Index()
        {
            return View();
        }

        [HttpGet]
        [DisableAuditing]
        [WrapResult(false, false)]//关闭ABP的返回数据封装
        public async Task<IActionResult> GetCommodityReviewsData(int page, int limit)
        {
            var data = await _commodityReviewsAppService.GetCommodityReviewsLayerDataAsync(page, limit);
            return Json(data);
        }

        public async Task<IActionResult> Edit(Guid id)
        {
            var entity =await _commodityReviewsAppService.GetById(id);
            return View(entity);
        }

        public async Task<IActionResult> Delete(Guid id)
        {
            await _commodityReviewsAppService.DeleteCommodityReviews(id);
            return Json(id);
        }
    }
}